/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef GLUCK_H
#define GLUCK_H

#include <string>
#include <filesystem/String.hpp>

namespace liba
{

/**	This class is used as the general-purpose exception class.
	It is thrown, when the critical error occurs in the library code.
	If this happens, the user of the library can do nothing to 
	continue the execution of his application. 
	Gluck is not inherited from std::exception because of the bug
	in std::exception implementation in Microsoft Visual Studio 6 STL. 
	@todo inherit Gluck from std::exception, when the MSVC STL is fixed.*/
class Gluck
{
	/** String can be used, because it's copying does not allocate memory. */
	std::string description;
	std::string place;
public:
	Gluck( const std::string & place, const std::string & description );
	virtual ~Gluck()
	{}
	const std::string & get_description()const
	{
		return description;
	}
	const std::string & get_place()const
	{
		return place;
	}
};

class GluckBadResource : public Gluck
{
	filesystem::String resource_name;
public:
	GluckBadResource( const std::string & place, const std::string & description, const filesystem::String & resource_name );
	const filesystem::String & get_resource_name()const
	{
		return resource_name;
	}
};

} // namespace liba
using namespace liba;

#ifdef ANDROID_NDK
//#define THROW(x) { (x, exit(123)) }
#define THROW(x) do { x, *reinterpret_cast<char*>(0x10) = 0xFF; } while (0)
#else

#ifdef IPHONE_VERSION
#ifndef _DEBUG
#define THROW(x) throw x
#else
#define THROW(x) throw x
#endif
#else
//#define THROW(x) throw x
#define THROW(x) do { x, *reinterpret_cast<char*>(0x10) = 0xFF; } while (0)
#endif

#endif	//ANDROID_NDK

#endif //GLUCK_H

